#include "src/misc.h"
#include <gtest/gtest.h>

using namespace std;
using namespace cv;


class TestNearestPair: public testing::TestWithParam<int> {
protected:
    double getDistance(vector<TGPoint>& pts) {
        pair<TGPoint, TGPoint> pp;
        return nearestPairWithDivideAndConquer(pts, pp);
    }
};

TEST_P(TestNearestPair, case1) {
    int seed = GetParam();
    RNG rng(seed);
    vector<TGPoint>pts;
    generateRandomPointSet(30, rng, pts);
    double d1 = nearestPairWithBruteForce(pts);
    double d2 = getDistance(pts);
    //printf("%.3f, %.3f\n", d1, d2);
    EXPECT_DOUBLE_EQ(d1, d2);
}


INSTANTIATE_TEST_CASE_P(test, TestNearestPair, testing::Range(0, 10));



int main(int argc, char* argv[]) {
    ::testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
}